//------------------------------------------------------------------------
// <copyright file="LookupControl.cs" company="DevDir">
//   Copyleft (c) DevDir. No rights reserved.
// </copyright>
// <author>Nikita Sharov</author>
//------------------------------------------------------------------------

namespace DevDir.Mp3.Equilibrist.Controls
{
  using System.Windows.Forms;
  
  public partial class LookupControl : BaseControl
  {
    // HACK: Bad naming.
    private BindingSource originalBindingSource = new BindingSource();
    private BindingSource newBindingSource = new BindingSource();
    
    /// <summary>
    /// Initializes a new instance of the <b>LookupControl</b> class.
    /// </summary>
    public LookupControl()
    {
      InitializeComponent();

      this.originalMetaDataControl.Text = "Original Meta Data:";
      this.originalMetaDataControl.DataSource =
        this.originalBindingSource;
      this.newMetaDataControl.Text = "New Meta Data:";
      this.newMetaDataControl.DataSource = this.newBindingSource;

      this.SetUp(this.originalDataGridView);
      this.SetUpDataBindings(
        this.originalDataGridView, this.originalBindingSource);
      this.SetUp(this.newDataGridView);
      this.SetUpDataBindings(
        this.newDataGridView, this.newBindingSource);
    }

    public BindingSource OriginalBindingSource
    {
      get { return this.originalBindingSource; }
      set { this.originalBindingSource = value; }
    }

    public BindingSource NewBindingSource
    {
      get { return this.newBindingSource; }
      set { this.newBindingSource = value; }
    }

    private void SetUpDataBindings(
      DataGridView dataGridView, object dataSource)
    {
      dataGridView.AutoGenerateColumns = false;
      dataGridView.DataSource = dataSource;

      DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn();
      c.HeaderText = "Artist";
      c.DataPropertyName = "Artist";
      c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      c.FillWeight = 20;
      dataGridView.Columns.Add(c);

      c = new DataGridViewTextBoxColumn();
      c.HeaderText = "Year";
      c.DataPropertyName = "Year";
      c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      c.FillWeight = 10;
      dataGridView.Columns.Add(c);

      c = new DataGridViewTextBoxColumn();
      c.HeaderText = "Album";
      c.DataPropertyName = "Album";
      c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      c.FillWeight = 20;
      dataGridView.Columns.Add(c);

      c = new DataGridViewTextBoxColumn();
      c.HeaderText = "Track";
      c.DataPropertyName = "Track";
      c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      c.FillWeight = 10;
      dataGridView.Columns.Add(c);

      c = new DataGridViewTextBoxColumn();
      c.HeaderText = "Title";
      c.DataPropertyName = "Title";
      c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      c.FillWeight = 30;
      dataGridView.Columns.Add(c);

      c = new DataGridViewTextBoxColumn();
      c.HeaderText = "Duration";
      c.DataPropertyName = "Duration";
      c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      c.FillWeight = 10;
      dataGridView.Columns.Add(c);
    }
  }
}
